package cn.wsalix.finance.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.validator.constraints.Email;

import cn.anlaser.entity.SimpleEntity;

@Entity
@DynamicInsert @DynamicUpdate
@Table(name = "CREDIT_CARD")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Data
@EqualsAndHashCode(callSuper=false)
public class CreditCard extends SimpleEntity  {

	private static final long serialVersionUID = 1866474821139185112L;

	private String cardNum;//卡号
	private Integer limitMax;//卡片额度
	private Integer initAmount;//初始消费金额
	@Temporal(TemporalType.DATE) //初始日期
	private Date initday;
	
	private Integer wasteAmount;//已消费金额
	
	private Integer currentAmount;//当前账单金额
	
	private Integer serverAmount;//服务费金额
	
	@Temporal(TemporalType.DATE) //账单日
	private Date billday;
	@Temporal(TemporalType.DATE) //还款日
	private Date repaymentday;
	private String mobile;
	@Email
	private String email;
	
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_CREDITCARD_CUSTOMER"), name = "CUSTOMER_ID")
	private Customer customer;
	
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_CARD_BANK"), name = "BANK_ID")
	private Bank bank;
}
